﻿<%@ Page Language="C#" MasterPageFile="~/Admin/Admin.master" AutoEventWireup="true"
    CodeFile="TicketList.aspx.cs" Inherits="Admin_TicketList" Title="Untitled Page" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <br />
    <b><span style="font-size: 16pt">Ticket List</span></b><asp:SqlDataSource ID="SqlDataSource1"
        runat="server" ConnectionString="<%$ ConnectionStrings:sqlString %>" SelectCommand="SELECT Airline_Ticket.TicketID, Airline_Ticket.FlightID, Airline_Ticket.TicketStatus, Airline_Ticket.BoughtDay, Airline_Ticket.DiscountID, Airline_DiscountTimeTable.Discount, Airline_DiscountTimeTable.DiscountType, vw_aspnet_MembershipUsers.UserName FROM Airline_Ticket INNER JOIN Airline_DiscountTimeTable ON Airline_Ticket.DiscountID = Airline_DiscountTimeTable.DiscountID INNER JOIN vw_aspnet_MembershipUsers ON Airline_Ticket.UserID = vw_aspnet_MembershipUsers.UserId"
        DeleteCommand="DELETE FROM [Airline_Ticket] WHERE [TicketID] = @TicketID" InsertCommand="INSERT INTO [Airline_Ticket] ([UserID], [FlightID], [TicketStatus], [BoughtDay], [DiscountID]) VALUES (@UserID, @FlightID, @TicketStatus, @BoughtDay, @DiscountID)"
        
        UpdateCommand="UPDATE [Airline_Ticket] SET [UserID] = @UserID, [FlightID] = @FlightID, [TicketStatus] = @TicketStatus, [BoughtDay] = @BoughtDay, [DiscountID] = @DiscountID WHERE [TicketID] = @TicketID">
        <DeleteParameters>
            <asp:Parameter Name="TicketID" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="UserID" Type="Object" />
            <asp:Parameter Name="FlightID" Type="Int32" />
            <asp:Parameter Name="TicketStatus" Type="String" />
            <asp:Parameter Name="BoughtDay" DbType="Date" />
            <asp:Parameter Name="DiscountID" Type="Int32" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="UserID" Type="Object" />
            <asp:Parameter Name="FlightID" Type="Int32" />
            <asp:Parameter Name="TicketStatus" Type="String" />
            <asp:Parameter Name="BoughtDay" DbType="Date" />
            <asp:Parameter Name="DiscountID" Type="Int32" />
            <asp:Parameter Name="TicketID" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>
    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False"
        CellPadding="3" DataKeyNames="TicketID" DataSourceID="SqlDataSource1" GridLines="None"
        BackColor="White" BorderColor="White" BorderStyle="Ridge" 
        BorderWidth="2px" CellSpacing="2"
        AllowSorting="True">
        <RowStyle BackColor="#DEDFDE" ForeColor="Black" />
        <Columns>
            <asp:HyperLinkField DataNavigateUrlFields="TicketID" DataNavigateUrlFormatString="EditTicket.aspx?id={0}"
                HeaderText="Edit" Text="Edit" />
            <asp:BoundField DataField="TicketID" HeaderText="Ticket ID" InsertVisible="False"
                ReadOnly="True" SortExpression="TicketID" />
            <asp:BoundField DataField="UserName" HeaderText="User" 
                SortExpression="UserName" />
            <asp:BoundField DataField="FlightID" HeaderText="Flight ID" SortExpression="FlightID" />
            <asp:BoundField DataField="TicketStatus" HeaderText="Ticket Status" SortExpression="TicketStatus" />
            <asp:BoundField DataField="BoughtDay" HeaderText="Bought Day" SortExpression="BoughtDay" />
            <asp:BoundField DataField="Discount" DataFormatString="{0} %" HeaderText="Discount"
                SortExpression="Discount" />
            <asp:BoundField DataField="DiscountType" HeaderText="Reason" SortExpression="DiscountType" />
            <asp:HyperLinkField Text="Details" DataNavigateUrlFields="TicketID" DataNavigateUrlFormatString="~/Admin/TicketDetail.aspx?TicketID={0}" />
        </Columns>
        <FooterStyle BackColor="#C6C3C6" ForeColor="Black" />
        <PagerStyle BackColor="#C6C3C6" ForeColor="Black" HorizontalAlign="Right" />
        <SelectedRowStyle BackColor="#9471DE" Font-Bold="True" ForeColor="White" />
        <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#E7E7FF" />
    </asp:GridView>
    <br />
    <br />
    </asp:Content>
